package myProject.gwt.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.TextBox;

public class KeyboardSimulator extends AbstractKeyboard {
	
	private HorizontalPanel panel = new HorizontalPanel();
	
	public KeyboardSimulator(){
		initWidget(panel);
		
		final TextBox textBox = new TextBox();
		textBox.setMaxLength(1);
		textBox.setPixelSize(30, 22);
		
		Button button = new Button("Send key");
		button.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				if(textBox.getText().length() > 0) {
					raiseKeyPressed(textBox.getText().charAt(0));
				}
			}			
		});
		
		panel.add(textBox);
		panel.add(button);
	}
}
